#!/usr/bin/perl -w
#
use warnings;
use strict;
 
# Get 3 DNA sequences from user and put them in an array
my @out;
for (my $i =0; $i<3; $i++){
    print "Please give a DNA sequence  ";
    my $seq1 = <STDIN>;chomp($seq1); 
    push(@out,complement($seq1));
}
# Loop through the array and write each complement
foreach my $e (@out){
   print("$e\n");
}

sub complement{
	# Get the sequence that was passed as a reference 
	my $s = shift(@_);
    my @seq = split(//, $s);
    my $out;
    #Loop through the sequence   
    my $index = 0;
    while ($index<= $#seq){
    # Assign the complement of each nucleotide
    if($seq[$index] eq 'A'){
        $out = $out.'T';
    }
     elsif($seq[$index] eq 'T'){
        $out = $out.'A';
    }
     elsif($seq[$index] eq 'C'){
        $out = $out.'G';
    }
     elsif($seq[$index] eq 'G'){
        $out = $out.'C';
    }
    else{
    	$out = $out.$seq[$index];
    }
    $index++;
    }
    return $out;
}


 